{extend name='table'}

{block name="button"}
<button data-modal='{:url("add")}' data-title="{:lang('添加')}" class='layui-btn layui-btn-sm layui-btn-primary'>添加</button>
<!--{if auth("remove")}-->
<button data-table-id="DownloadTable" data-action='{:url("remove")}' data-rule="id#{id}" data-confirm="确定要删除选中的下载器吗？" class='layui-btn layui-btn-sm layui-btn-primary'>{:lang('批量删除')}</button>
<!--{/if}-->

<!--{if auth("clear")}-->
<button data-table-id="DownloadTable" data-load='{:url("clear")}' data-confirm="确定要清空所有下载器吗？" class='layui-btn layui-btn-sm layui-btn-primary'>删除所有</button>
<!--{/if}-->
{/block}
{block name="content"}
<div class="think-box-shadow">
    <table id="DownloadTable" data-url="{:request()->url()}" data-target-search="form.form-search"></table>
</div>
{/block}
{block name='script'}
<script>
    $(function () {
        $('#DownloadTable').layTable({
            even: true, height: 'full',
            sort: {field: 'id', type: 'desc'},
            cols: [[
                {checkbox: true},
                // {field: 'id', title: 'ID', width: 80, sort: true, align: 'center'},
                {field: 'name', title: '名称',  width: '8%', align: 'center'},
                {field: 'type', title: '类型',width: '8%', align: 'center'},
                {field: 'host', title: '地址', align: 'center'},
                {field: 'port', title: '端口', align: 'center'},
                {field: 'username', title: '登录用户名', width: '10%', align: 'center'},
                {field: 'password', title: '登录密码', align: 'center'},
                {field: 'is_skip_hash', title: '跳过哈希校验', align: 'center'},
                {field: 'is_paused', title: '自动开始', align: 'center'},
                {field: 'reseed_sites_name', title: '辅种站点', align: 'center', sort: true,  templet: '#sitesTps'},
                {field: 'status', title: '状态', align: 'center', sort: true,  templet: '#statusTpl'},
                {toolbar: '#toolbar', title: '{:lang("操作面板")}', align: 'center', minWidth: 90, width: '15%', fixed: 'right'}
            ]]
        });
    });
</script>
<script type="text/html" id="toolbar">
  <a data-action='{:url("connectCheck")}' data-value="id#{{d.id}}" class="layui-btn layui-btn-sm layui-btn-primary layui-border-re">测试</a>
    <a class="layui-btn layui-btn-sm" data-event-dbclick data-title="{:lang('编辑')}" data-modal='{:url("edit")}?id={{d.id}}'>{:lang('编 辑')}</a>
    <!--{if auth('remove')}-->
    <a data-action='{:url("remove")}' data-value="id#{{d.id}}" data-confirm="确认要删除这条记录吗？" class="layui-btn layui-btn-sm layui-btn-danger">{:lang('删 除')}</a>

    <!--{/if}-->
</script>
<script type="text/html" id="statusTpl">
  {{# if(d.status == 1){ }}
      <button class="layui-btn layui-btn-sm layui-btn-primary layui-border-green">启用</button>
  {{# } else { }}
      <button class="layui-btn layui-btn-sm layui-btn-primary layui-border-re">禁用</button>
  {{# } }}
</script>
{/block}